Dev_Tasks
Implementation of serial protocol using Serial I/O COMMREQs may be restricted by the PLC sweep time. Serial I/O is completely driven by the application program, in STOP mode a port configured as Serial I/O reverts to SNP slave for programmer. Serial I/O protocol allows users to write a custom protocol for communicating with various serial devices such as bar code readers or pagers (not all CPUs support both Serial I/O modes). Serial I/O has two modes: Read and Write.
Reference: Series 90 PLC Serial Communications Users Manual GFK-0582D.
#END#

Configure Port
All Series 90-30 CPUs have a built-in serial port that is accessed through a connector on the PLC power supply. CPUs 351, 352, and 363 each have two additional serial ports that are accessed by connectors on their faceplates. These three CPUs (IC693CPU351/352/363) have three serial ports. The standard SNP port is accessed through the power supply connector. Ports 1 and 2 are accessed by connectors on the front of the module (shown in the figure below). For many applications, each port serves as an independent window into the PLC for communicating with other devices, such as industrial computers, pagers, and operator interface terminals. Ports 1 and 2 can also be configured using a Communications Request (COMMREQ) Instruction in a ladder logic program. 
Port 1, the top port on these CPUs, is a non-isolated RS-232 compatible port. Port 1 is accessed through a 6-pin RJ-11 connector on the front of the module. This connector has female contacts and is similar to modular jacks commonly used for telephones and modems. GE Fanucs serial cable, part number IC693CBL316, is a convenient way to connect to this port. Chapter 8 of this manual contains a data sheet on this cable. 
Port 2, the bottom port, is an isolated, RS-485 compatible port. It is accessed through a female, 15-pin, D-shell connector on the front of the module. 
Standard SNP Port, accessed through the female, 15-pin, D-shell connector on the PLC power supply, is a non-isolated RS-485 compatible port.
#END#

Initialize Port 4300 
This function causes a reset command to be sent to the specified port. It also cancels any COMMREQ currently in progress and flushes the internal input buffer. RTS is set to inactive.
#END#

Set Up Input Buffer 4301	
This function can be used to change the size of the internal memory buffer where input data will be placed as it is received. By default, the buffer is set to a maximum of 2K bytes. As data is received from the serial port it is placed in the input buffer. If the buffer becomes full, any additional data received from the serial port is discarded and the
Overflow Error bit in the Port Status word is set. 
Retrieving Data from the Buffer: Data can be retrieved from the buffer using the Read String or Read Bytes function. It is not directly accessible from the application program. If data is not retrieved from the buffer in a timely fashion, some characters may be lost.
#END#

Flush Input Buffer 4302	
This operation empties the input buffer of any characters received through the serial port but not yet retrieved using a read command. All such characters are lost.
#END#

Read Port Status 4303	
This function returns the current status of the port. The following events can be detected:
1. A read request was initiated previously and the required number of characters has now been received or the specified time-out has elapsed.
2. A write request was initiated previously and transmission of the specified number of characters is complete or a time-out has elapsed.
The Port Status data returned by this function indicates the status of various tasks, such as whether or not a task was successfully completed. Each bit in the status word has a separate meaning, so the status of several items can be determined with one of these COMMREQs. A second Port Status word reports on the remaining number of characters in the input buffer. The Port Status memory type (address + 7) can specify either bit type (i.e. %M) or word type (i.e. %R) memory. Bit type memory does not have to be byte-aligned. Memory codes are found earlier in this chapter. Port Status memory consists of two words worth of data. So if bit type memory is specified, 32 consecutive bits (two words worth) will be used starting with the bit specified by address +8 of the Command Block. If word type memory is specified, two consecutive words will be used starting with the word specified by address +8 of the Command Block.
Port Status Words: The port status consists of two words: (1) a word reporting the status of various communication functions, and (2) a word reporting the number of characters in the input buffer that have not been retrieved by the application (characters which have been received and are available).
The following table details the meaning of each bit in Port Status Word 1:
Bit 	Name 	Definition 		Meaning
15 	RI 	Read In progress 		Set 	Read Bytes or Read String invoked
					Cleared 	Previous Read bytes or String has timed out, been canceled, or finished
14 	RS 	Read Success 		Set 	Read Bytes or Read String has successfully completed
					Cleared 	New Read Bytes or Read String invoked
13 	RT 	Read Time-out 		Set 	Receive timeout occurred during Read Bytes or Read String
					Cleared 	New Read Bytes or Read String invoked
12 	WI 	Write In progress 		Set 	New Write Bytes invoked
					Cleared 	Previously-invoked Write Bytes has timed out, been canceled, or finished
11 	WS 	Write Success 		Set 	Previously-invoked Write Bytes has successfully completed
					Cleared 	New Write Bytes invoked
10 	WT 	Write Time-out 		Set 	Transmit timeout occurred during Write Bytes
					Cleared 	New Write Bytes invoked
9 	CA 	Character Available 	Set 	Unread characters are in the buffer
					Cleared 	No unread characters in the buffer
8 	OF 	OverFlow error 		Set 	Overflow error occurred on the serial port or internal buffer
					Cleared 	Read Port Status invoked. (Cleared after port status is read.)
7 	FE 	Framing Error 		Set 	Framing error occurred on the serial port
					Cleared 	Read Port Status invoked. (Cleared after port status is read.)
6 	PE 	Parity Error 		Set 	Parity error occurred on the serial port
					Cleared 	Read Port Status invoked. (Cleared after port status is read.)
5 	CT 	CTS is active 		Set 	CTS line on the serial port is active or the serial port does not have a CTS line
					Cleared 	CTS line on the serial port is not active
4 - 0 	U 	not used, should be 0
#END#

Write Port Control 4304
Write Port Control 4304: This function forces RTS for the specified port:
Operating Notes:
1. For CPU port 2 (RS-485), the RTS signal is tied to the transmit driver. Therefore, control of RTS is dependent on the current state of the transmit driver. If the transmit driver is not enabled, asserting RTS with the Write Port Control COMMREQ will not cause RTS to be asserted on the serial line. The state of the transmit driver is controlled
by the protocol and is dependent on the current Duplex Mode of the port. For 2-wire and 4-wire Duplex Mode, the transmit driver is only enabled during transmitting. Therefore, RTS on the serial line will only be seen active on port 2 (configured for 2-wire or 4-wire Duplex Mode) when data is being transmitted. For point-to-point Duplex Mode, the transmit driver is always enabled. Therefore, in point-to-point Duplex Mode, RTS on the serial line will always reflect what is chosen with the Write Port Control COMMREQ. 
2. Configuring the port control status word can be facilitated by entering the value for the Port Control word (address +7) in hexadecimal format: 
a) Use 8000 (hex) to activate RTS (this places a 1 in bit 15, and a 0 in the other bits)
b) Use 0000 to deactivate RTS
#END#

Cancel Operation 4399	
This function cancels the current operations in progress. It can be used to cancel all operations, read operations, or write operations. If a read operation is in progress and there are unprocessed characters in the input buffer, those characters are left in the input buffer and available for future reads. The serial port is not reset.
This function does not update the status of words of the cancelled COMMREQs. 
Caution: If this COMMREQ is sent in either Cancel All or Cancel Write mode when a Write Bytes (4401) COMMREQ is transmitting a string from a serial port, transmission is halted. The position within the string where the transmission is halted is indeterminate. In addition, the final character received by the device the CPU is sending to is also indeterminate.
#END#

Autodial 4400	
The Autodial command automatically transmits an Escape sequence that follows the Hayes convention. If you are using a modem that does not support the Hayes convention, you may be able to use the Write Bytes command to dial the modem. This feature allows the CPU to automatically dial a modem and send a specified byte string. To implement this feature, the port must be configured for Serial I/O.
For example, pager enunciation can be basically implemented by three commands, requiring three COMMREQ command blocks:
Autodial: 04400 (1130h) Dials the modem.
Write Bytes: 04401 (1131h) Specifies an ASCII string, from 1 to 250 bytes in length, to send from the serial port.
Autodial: 04400 (1130h) It is the responsibility of the PLC application program to hang up the phone connection. This is accomplished by reissuing the autodial command and sending the hang up command string.
#END#

Write Bytes 4401	
This operation can be used to transmit one or more characters to the remote device through the specified serial port. The character(s) to be transmitted must be in a word reference memory. They should not be changed until the operation is complete. Up to 250 characters can be transmitted with a single invocation of this operation. The status of the operation is not complete until all of the characters have been transmitted or until a timeout occurs (for example, if hardware flow control is being used and the remote device never enables the transmission).
Caution: If an Initialize Port (4300) COMMREQ is sent or a Cancel Operation (4399) COMMREQ is sent in either Cancel All or Cancel Write mode while this COMMREQ is transmitting a string from a serial port, transmission is halted. The position within the string where the transmission is halted is indeterminate. In addition, the final character received by the device the CPU is sending to is also indeterminate.
#END#

Read Bytes 4402	
This function causes one or more characters to be read from the specified port. The characters are first read into an internal input buffer, then read from there into the data area specified in the COMMREQs Command Block. The function returns both the number of characters retrieved and the number of unprocessed characters still in the input buffer. If zero characters of input are requested, only the number of unprocessed characters in the input buffer is returned. If insufficient characters are available to satisfy the request and a non-zero value is specified for the number of characters to read, the status of the operation is not complete until either sufficient characters have been received or the time-out interval expires. In either of those conditions, the Port Status words indicate the reason for completion of the read operation. The Port Status words are not updated until the read operation is complete (either due to timeout or when all the data has been received). You can use the Read Port Status Function COMMREQ (4303) to access the status information. If the time-out interval is set to zero, the COMMREQ remains pending until it has received the requested amount of data, or until it is cancelled. If this COMMREQ fails for any reason, no data is returned to the buffer. Any data that was already in the buffer remains, and can be retrieved with a subsequent read request.
#END#

Read String 4403	
This function causes characters to be read from the specified port until a specified terminating character is received. The function returns both the number of characters retrieved and the number of unprocessed characters still in the input buffer. If zero characters of input are requested, only the number of unprocessed characters in the input buffer are returned. If the terminating character is not in the input buffer, the status of the operation is not complete until either the terminating character has been received or the time-out interval expires. In either of those conditions, the port status indicates the reason for completion of the read operation. If the time-out interval is set to zero, the COMMREQ remains pending until it has received the requested string, terminated by the specified end character. If this COMMREQ fails for any reason, no data is sent to the buffer. Any data that was already in the buffer remains, and can be retrieved with a subsequent read request.
The return data consists of the number of characters actually read, the number of characters still available in the input buffer after the read is complete (if any), and the actual input characters:
Address 		Number of characters actually read
Address + 1 	Number of characters still available in the input buffer, if any
Address + 2 	first two characters (first character is in the low byte)
Address + 3 	third and fourth characters (third character is in the low byte)
Address + n 	subsequent characters
Return Data Block Size
The Return Data memory block, shown above, will consist of:
  One word to store the number of characters read
  One word to store the number of characters still in the input buffer
  One word for every two characters actually read.
So, for example, if 24 characters were read, the data block would be 14 words long. Be sure to allow sufficient room in user memory for this data block.
#END#

Commreq_Task_No	
Not Available
#END#

Data_Block_Len	
Not Available
#END#

Buffer_Length	
In WORDS. It is not possible to set the buffer length to zero. If zero is entered as the buffer length, the buffer size will be set to the 2K bytes default. If a length greater than 2K bytes is specified, an error is generated.
#END#

Wait_Flag	
This flag determines whether PLC will wait until the device serial ports receive the intended data before continuing. The request can either send a message and wait for a reply, or send a message and continue without waiting for a reply. If the Command Block specifies that the program will not wait for a reply, the Command Block contents are sent to the device and ladder program execution resumes immediately. This is referred to as NOWAIT mode. If the Command Block specifies that the program will wait for a reply, the Command Block contents are sent to the targeted device and the CPU waits for a reply for a maximum length of time specified in the Command Block. If the device does not respond in that time, ladder program execution resumes. This is referred to as WAIT mode.
#END#

Idle_Tmout	
The idle timeout value is the maximum time the PLC waits for the device to acknowledge receipt of the request. For NOWAIT, this value is not used. (Any timeout value is ignored; it can be zero.) If WAIT is selected, this word specifies the idle timeout period, in 100-microsecond increments.
#END# 

Max_Comm_Tm	
This word contains the maximum amount of time the program should hold the window open when the device is busy. For NOWAIT, this value is not used. (Any timeout value is ignored; it can be zero.) If WAIT is selected, this word specifies the maximum time in 100 microsecond increments.
#END#

Command_Word	
Not Available
#END#

Task_Id	
19 for Port 1 and 20 for port 2
#END#

Port_Status_Memory_Type	
Port_Status_Memory_Type
#END#

Port_Status_Memory_Offset	
Port_Status_Memory_Offset	
#END#

Port_Control_Word	
32768 to activate RTS and 0 to deactivate
#END#

Transac_Type	
Caution: If this COMMREQ is sent in either Cancel All or Cancel Write mode when a Write Bytes (4401) COMMREQ is transmitting a string from a serial port, transmission is halted. The position within the string where the transmission is halted is indeterminate. In addition, the final character received by the device the CPU is sending to is also indeterminate.
#END#

Modem_Tmout	
Modem_Tmout
#END#

No_Bytes_Cmd	
Not Available
#END#

Cmd_String	
Enter command string. The Autodial command automatically transmits an Escape sequence that follows the Hayes convention. If you are using a modem that does not support the Hayes convention, you may be able to use the Write Bytes command to dial the modem.

For inserting '<CR>' in the command just press 'Enter'.
#END#

Xmit_Tmout	
Note: Specifying zero as the Transmit time-out sets the time-out value to the amount of time actually needed to transmit the data, plus 4 seconds.
#END#

No_Bytes_Write	
Not Available
#END#

Write_String	
Enter String to be written.
#END#

Read_Tmout	
Read timeout
#END#

No_Bytes_Read	
Not Available
#END#

Input_Data_Mem_Type	
Memory type for input data.
#END#

Read_Term_Charac	
Terminating Character (Carriage Return) Must be between 0 and 255, inclusive
#END#

Input_Data_Mem_Off	
Not Available
#END#

Protocol	
Not Available
#END#

Port_Mode	
Mode of the port: Master /Slave/ Peer.
#END#

Data_Rate	
Rate of data transmission.
#END#

Parity	
A bit added to a memory word to make the sum of the bits in a word always even (even parity) or always odd (odd parity).
#END#

Flow_Control	
The Flow Control field specifies the method of flow control to use at this serial port. Note: The CMM modules do not support hardware flow control when used with an
RS-485 interface. The NONE selection makes use of the signals Transmit Data (TD) and Receive Data (RD) only. The signal Request to Send (RTS), however, is used as a modem keying signal. The RTS signal is energized for the Modem Turnaround Delay interval and during the character transmission; the RTS signal is then immediately de-energized. The HARDWARE selection makes use of the Transmit Data (TD), Receive Data (RD), Request to Send (RTS, Clear to Send (CTS), Data Carrier Detect (DCD), and Data Terminal Ready (DTR). The signals are used in the manner specified by the RS-232 and RS-422/RS-485 electrical standards. 
Request to Send (RTS) and Clear to Send (CTS). These signals are used to control the transmission of data to the remote device. The RTS signal is asserted at the beginning of each transmission by the CMM. The actual characters are not transmitted, however, until the CTS signal is returned. Once the characters are transmitted, the RTS signal is immediately removed. As in the case of NONE flow control, a nonzero Modem Turnaround Delay is NOT used to control the operation of the RTS signal. It is simply used to adjust the appropriate protocol timers for any delay in receiving the CTS signal once the RTS signal is asserted. Data Carrier Detect (DCD) and Data Terminal Ready (DTR). These signals are used to control the reception of data from the remote device. The DCD signal, when received from the remote device, essentially forms a request to the CMM to prepare for reception of data. The CMM, in turn, asserts the DTR signal when it is prepared to receive the data. In the CMM, DTR is always asserted; it is never turned off.
#END#

Turn_Delay	
The Modem Turnaround Delay field specifies the length of time required by the intervening modems to turn the link around. In the case that NONE flow control is selected, the Modem Turnaround Delay also specifies the length of time that the Request to Send (RTS) signal is asserted before any characters are transmitted.
#END#

TmOut	
The Timeout field displays the length of timeouts used.
#END#

BPC	
Bits per character
#END#

Stop_Bit	
Number of stop bits
#END#

Duplex_Mode	
Not Available
#END#

Rack_No	
For CPU constant 1
#END#

Slot_No_CPU	
Constant 1
#END#
